#ifndef MYTEXTEDIT_H
#define MYTEXTEDIT_H

#include <QContextMenuEvent>
#include <QString>
#include <QTextEdit>



class MyTextEdit : public QTextEdit
{
    Q_OBJECT
public:
    explicit MyTextEdit(QWidget *parent = nullptr, QString filePath = "", bool isExisted = false);
    bool save();
    bool saveAs();
    bool open(QString filePath);
    QString getCurPath();
    void setCurPath(QString newPath);
    QString getFileName();
    void setFileName(QString newName);
    QString getFilePath();
protected:
    void closeEvent(QCloseEvent *event);
    void contextMenuEvent(QContextMenuEvent *event);
protected slots:
    void isModified();
private:
    QString fileName; //当前文件名
    QString curPath; //当前文件地址（默认为输出目录，带最后的分割线）
    bool isSaved; //提供是否保存的标志，用于标题显示
};

#endif // MYTEXTEDIT_H
